package com.demo1;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author: shilvfa
 * @date: 2025-03-25 21:57
 * @email:shilfwh@163.com
 * @Description:
 */
public class 处理百度网盘指数文件 {
    public static void main(String[] args) {
        String fileName = "F:\\BaiduNetdiskDownload\\指数高频\\2025.1-3指数\\汇总";
        File file = new File(fileName);
        File[] files = file.listFiles();
        for (File f : files) {
            if (f.isDirectory()) {

                File[] subFiles = f.listFiles();
                for (File subFile : subFiles) {
                    if (subFile.getName().equals("SH.000016.csv") ||
                            subFile.getName().equals("SH.000300.csv") ||
                            subFile.getName().equals("SH.000905.csv") ||
                            subFile.getName().equals("SH.000852.csv")) {

                        //复制到指定目录
                        String targetSubDirPath = "F:\\BaiduNetdiskDownload\\指数高频\\2025.1-3指数\\筛选\\" + f.getName();
                        File targetSubDir = new File(targetSubDirPath);
                        if (!targetSubDir.exists()) {
                            targetSubDir.mkdirs();
                        }
                        Path sourcePath = Paths.get(subFile.getAbsolutePath());
                        Path targetPath = Paths.get(targetSubDirPath + "\\" + subFile.getName());
                        try {
                            //复制文件
                            Files.copy(sourcePath, targetPath);
                        } catch (Exception e) {
                            e.printStackTrace();

                        }
                    }
                }
            }
        }
    }
}
